using System;
using RequestLog.Configuration;

namespace RequestLog.MySql
{
    /// <summary>
    /// 
    /// </summary>
    public static class OptionsExtensions
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="options"></param>
        /// <param name="connectionString"></param>
        /// <returns></returns>
        public static RequestLogOptions UseMySql(this RequestLogOptions options, string connectionString)
        {
            return options.UseMySql(opt => { opt.ConnectionString = connectionString; });
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="options"></param>
        /// <param name="configure"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"></exception>
        public static RequestLogOptions UseMySql(this RequestLogOptions options, Action<MySqlOptions> configure)
        {
            if (configure == null)
            {
                throw new ArgumentNullException(nameof(configure));
            }

            options.RegisterExtension(new MySqlOptionsExtension(configure));

            return options;
        }

        // /// <summary>
        // /// 
        // /// </summary>
        // /// <param name="options"></param>
        // /// <typeparam name="TContext"></typeparam>
        // /// <returns></returns>
        // public static RequestLogOptions UseEntityFramework<TContext>(this RequestLogOptions options)
        //     where TContext : DbContext
        // {
        //     return options.UseEntityFramework<TContext>(opt => { });
        // }
        //
        // /// <summary>
        // /// 
        // /// </summary>
        // /// <param name="options"></param>
        // /// <param name="configure"></param>
        // /// <typeparam name="TContext"></typeparam>
        // /// <returns></returns>
        // /// <exception cref="ArgumentNullException"></exception>
        // public static RequestLogOptions UseEntityFramework<TContext>(this RequestLogOptions options, Action<EfOptions> configure)
        //     where TContext : DbContext
        // {
        //     if (configure == null)
        //     {
        //         throw new ArgumentNullException(nameof(configure));
        //     }
        //
        //     options.RegisterExtension(new MySqlOptionsExtension(x =>
        //     {
        //         configure(x);
        //         x.DbContextType = typeof(TContext);
        //     }));
        //
        //     return options;
        // }
    }
}